package ru.papergames.model.binsocket.packets
{
	import ru.papergames.model.binsocket.data.ExtByteArray;
		
	public class SocketRequest extends BaseSocketPacket
	{
		public static const NOTIFICATION:String = 'SocketRequest.GENERIC_SOCKET_REQUEST';
		
		public function SocketRequest(reqID:uint)
		{
			super();
			this.packetID = reqID;
			binaryData = new ExtByteArray();
		}
		
		public final function getBytes():ExtByteArray {
			encode();
			return this.binaryData;
		}
		
		private function encode():void {
			binaryData.cleanup();
			
			//count stub
			binaryData.writeShort(0);
			
			binaryData.writeByte(this.packetID);
			
			var body:ExtByteArray = getPacketBody();
			
			if (body) binaryData.writeBytes(body, 0, body.length);
			
			//cals size
			binaryData.validateSize();
		}
		
		protected function getPacketBody():ExtByteArray {
			return null;
		}
		
		public function getNotification():String {
			return NOTIFICATION;
		}
				
	}
}